<%@page import="com.sinba.common.system.dto.IMessageDTO"%>
<%@page import="com.sinba.common.dto.PageDTO"%>
<%@page import="com.sinba.common.system.service.IIMessageService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>
<%
int pages = 1;
if(request.getParameter("pages")!=null && request.getParameter("_pages")!=""){
	pages = Integer.parseInt(request.getParameter("pages"));
}
if(session.getAttribute("password2")==null){
	/* response.sendRedirect( "login2.jsp?pageUrl=user/imessage.jsp");
	return; */
}
ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
IIMessageService imessageService = (IIMessageService)ac.getBean("imessageService");
IMessageDTO imessageDto = new IMessageDTO();
int rows = 10;imessageDto.setLimit( rows );
int start = ( pages - 1 ) * rows;imessageDto.setStart( start );
imessageDto.setLoginName((String)session.getAttribute("loginName"));
PageDTO pageDTO = imessageService.findPageIMessage(imessageDto,"desc","createTime"); 
if ( pageDTO != null ){ pageDTO.setPage( pages ); pageDTO.setRows( rows );
}
request.setAttribute("pageDTO",pageDTO);
request.setAttribute("pageUrl","imessage.jsp?loginName="+imessageDto.getLoginName());
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><fmt:message key="i18n.emailManage"/>-<fmt:message key="i18n.title"/>  </title>
<link rel="shortcut icon" href="../index/favicon.png" />
<link rel="stylesheet" type="text/css" href="${basePath}user/css/style1.css">
<script type="text/javascript" src="${basePath}scripts/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="${basePath}scripts/script.js"></script>
<style type="text/css">
.messageAdd textarea {resize: none;border: 1px solid;font-size: 18px;}
</style>
</head>
<body style="background:#ffffed;">
<!-- 主体内容 -->
<div class="account">
	<div class="top2" style="background:#ffffed;">
	<a class="top2L" ><fmt:message key="i18n.moneyManage"/>  &gt;  <fmt:message key="i18n.message"/></a>
	<div class="top2R">&nbsp;</div>
	</div>
	<div class="cont" style="padding: 0;">
		<div>
			<table style="margin-top: 0px;" class="txList" width="100%" cellspacing="0" cellpadding="0">
				<tr>
	   				<th><fmt:message key="i18n.titleAndContent"/></th>
	   				<th><fmt:message key="i18n.sendUser"/></th>
	   				<th><fmt:message key="i18n.sendDate"/></th>
	   				<%-- <th><fmt:message key="i18n.status"/></th>
	   				<th>发送/接收</th> --%>
				</tr>
	   			<c:forEach items="${pageDTO.data}" var="data">
	   				<tr>
	   					<td width="50%">${data.message}</td>
	   					<td width="24%">${data.sendUser}</td>
	   					<td width="24%">
	   						<fmt:formatDate value="${data.sendDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
	   					</td>
	   					<%-- <td>${data.status}</td>
	   					<td>${data.mtype}</td> --%>
	   				</tr>
	   			</c:forEach>
	   			<c:if test="${empty pageDTO.data}">
	   				<tr>
	   					<td colspan="3" align="center"><fmt:message key="i18n.noData"/></td>
	   				</tr>
	   			</c:if>
			</table>
		</div>
		<div class="pageBox" style="margin-top: 40px;">
			<div class="page">
				<a style="color: blue;" href="${pageUrl }&pages=1"><fmt:message key="i18n.firstPage"/></a>
				<c:if test="${pageDTO.page > 1}">
					<a style="color: blue;" href="${pageUrl }&pages=${pageDTO.page-1}"><fmt:message key="i18n.upPage"/></a>
				</c:if>
				<a>${pageDTO.page}/${pageDTO.total}</a>
				<c:if test="${pageDTO.page+1<=pageDTO.total}">
					<a style="color: blue;" href="${pageUrl }&pages=${pageDTO.page+1}"><fmt:message key="i18n.nextPage"/></a>
				</c:if>
				<a style="color: blue;" href="${pageUrl }&pages=${pageDTO.total}"><fmt:message key="i18n.endPage"/></a>
				<a><fmt:message key="i18n.total"/>${pageDTO.totalSize}<fmt:message key="i18n.tiao"/></a>
			</div>
		</div>
		<hr>
		<div class="tx_Top messageAdd">
			<form action="imessage!sendMessage.action" method="post" >
				<input type="hidden" name="imessageDto.sendUser" value="${session.loginName}" />
				<input type="hidden" name="imessageDto.mtype" value="Send" />
				<input type="hidden" name="imessageDto.status" value="Unread" />
				<input type="hidden" name="imessageDto.receiveUser" value="System" />
				<table width="200px;" style="font-size: 18px;padding-top: 15px;">
					<tr>
						<td><span style="font-size: 18px;"> <fmt:message key="i18n.MessageContent" /></span> </td>
						<td>
							<textarea name="imessageDto.message" rows="10" cols="70"></textarea>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center">
							<input type="submit" class="ctrR1BoxAn" value="<fmt:message key="i18n.queding" />"/>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>
<script>

$(function(){
    $("#deleteEmail").click(function(){
    	$("#emailForm").submit();
    });
})
</script>

</body>
</html>